    	mui.init();
    	
    	//mui("#mySwitch").switch().toggle();
    	document.getElementById("mySwitch").addEventListener("toggle", function (event) {
    		if (event.detail.isActive) {
    			//console.log("你启动了开关");
    			map.setStatus({
    				dragEnable: true,
    			});
    		} else {
    			map.setStatus({
    				dragEnable: false,

    			});
    		}
    	})

    	var app = new Vue({

    		el: "#app",
    		data: {

    			buttonShow: false,
				dis:true
    		},
    		methods: {
    			StartEdit: function () {
    				this.buttonShow = !this.buttonShow;
    				circleEditor.open();

    			},
    			EndEdit: function () {
    				this.buttonShow = !this.buttonShow;

    				circleEditor.close();
					if(typeof circle === 'undefined' ||  
					circle.getCenter().getLat()<=0)
					{
						mui.alert('操作无效');
						return ;
					}
					
					//保存游戏属性
    				var requestUrl = url + "SaveFence/" + _grounpId + "|" +
    					circle.getCenter().getLng() + "|" + circle.getCenter().getLat() + "|" + circle.getRadius();
    				
    				axios.get(requestUrl)
    					.then(function (response) {
							//mui.alert('操作成功');
							mui.alert('操作成功！', '提示信息', '确定', function() {
							  SaveKnapsack();
							});
							
    					})
    					.catch(function (error) {
    						//console.log(error);
							mui.alert('操作异常');
    					});
					
					  //SaveKnapsack();	
    			},
				
				//重新生成
				ReCreate:function ()
				{
					ReCreateKnapsack(_ip,_grounpId);
					SetFitView();
				},
    		}
    	});
    	//var lon = 108.950543;
    	//var lat = 34.199175;
    	var circleEditor;
    	var circle;
    	var _grounpId;
    	var url;
    	var fenceRadius;
    	var json = {
    		"lon": 108.950544,
    		lat: 34.199176,
    		"grounpId": 167,
    		"ip": "192.168.100.63",
    		"fenceRadius": 1500
    	};
		
		var isTest = false;
		// if(isTest)
		// {
		// 	CreateAdminMap(json);
		// }
    
    	function CreateAdminMap(json) {
    		_grounpId = json.grounpId;
    		url = "http://" + json.ip + ":8899/";
    		//console.log(url);
			//alert(json.fenceRadius);
		
    		fenceRadius = json.fenceRadius;
    		map = new AMap.Map('container', {
    			resizeEnable: true,
    			center: [json.lon, json.lat],
    			showLabel: true,
    			mapStyle: "amap://styles/whitesmoke",
    			zoom: 13,
    			dragEnable: false
    		});
			//创建圆并缩放到合适的视野
    		createCircle(json);
    		SetRadius(fenceRadius);
			mui.alert('请拖动圆中心和周边的锚点,调整安全区域的位置和大小.',function (){
				
				InitKnapsack(json.ip,_grounpId);
				mui.alert('生成背包物资后，可以通过拖动手动调整其位置。',function (){
				});
			});
			setTimeout(function(){
				Init();
			},1500);
			
    	}
		

		function Init()
		{
			
			app.dis= false;
			//document.getElementById("setButton").disabled=false;
		}

    	function createCircle(json) {

    		circle = new AMap.Circle({
    			center: [json.lon, json.lat],
    			radius: fenceRadius, //半径
    			borderWeight: 3,
    			strokeColor: "#FF33FF",
    			strokeOpacity: 1,
    			strokeWeight: 6,
    			strokeOpacity: 0.2,
    			fillOpacity: 0.4,
    			strokeStyle: 'dashed',
    			strokeDasharray: [10, 10],
    			// 线样式还支持 'dashed'
    			fillColor: '#1791fc',
    			zIndex: 50,
    		})

    		circle.setMap(map)
    		// 缩放地图到合适的视野级别
    		map.setFitView([circle]);
    		circleEditor = new AMap.CircleEditor(map, circle);
    		//circleEditor.set

    		circleEditor.on('move', function (event) {
				//alert("move");
    		})

    		circleEditor.on('adjust', function (event) {
				//alert("adjust");
				//CreateKnapsack(_ip,_grounpId);
				//console.log("adjust");
				
    			SetRadius(circle.getRadius());
    			var grounpId = json.grounpId;
    		})

    		circleEditor.on('end', function (event) {

    			// event.target 即为编辑后的圆形对象
    			SetRadius(circle.getRadius());
    			var grounpId = json.grounpId;
    		})

    		circleEditor.open();

    	}


    	function Back() {
			if(!isTest)
			{
				window.location.href = "uniwebview://Back?num=1";
			}
    		
    	}
		function SaveKnapsack()
		{
			var array = [];
			for (var i = 0; i < kmarkArray.length; i ++) {
			    var  markObject = kmarkArray[i];
				 var jsonObj = new Object();
				 jsonObj["knapsack_info_id"] = markObject.inforId;
				 jsonObj["lat"] = markObject.getPosition().lat;
				 jsonObj["lon"] = markObject.getPosition().lng;
				 jsonObj["game_id"] = _grounpId;
				 array.push(jsonObj);
			 }
			 var json = JSON.stringify(array);
			 if(!isTest)
			 {
				  window.location.href = "uniwebview://SaveKnapsack?json=" + json;
			 }
			
		}